package zero.tech.games.gate.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zero.tech.core.data.Resp;
import zero.tech.core.data.SimpleUser;
import zero.tech.games.common.Code;
import zero.tech.games.common.ForbitUtil;
import zero.tech.games.common.TopicOrder;
import zero.tech.games.common.gm.GmForbitUser;
import zero.tech.games.common.gm.GmFreeRoom;
import zero.tech.games.gate.service.api.IGmService;
import zero.tech.redis.topic.TopicChannelType;
import zero.tech.redis.topic.service.api.IRedisMsgService;

@Service
public class GmServiceImpl implements IGmService{
	@Autowired
	private IRedisMsgService redisMsgService;
	@Autowired
	private ForbitUtil forbitUtil;
	@Override
	public Resp freeRoom(SimpleUser simpleUser,String room_id) {
		GmFreeRoom gmFreeRoom = new GmFreeRoom(room_id);
		redisMsgService.pulishRedisTopic(TopicChannelType.DEFAULT, TopicOrder.GM_FREE_ROOM, gmFreeRoom);
		return Resp.build(Code.OK, "发送释放成功");
	}
	@Override
	public Resp forbitSomeone(SimpleUser simpleUser, int uid, String service_id) {
		GmForbitUser gmForbitUser = new GmForbitUser(uid,service_id);
		forbitUtil.insertOrUpdate(gmForbitUser);
		redisMsgService.pulishRedisTopic(TopicChannelType.DEFAULT, TopicOrder.GM_FORBIT_USER, gmForbitUser);
		return Resp.build(Code.OK, "发送封禁账号成功");
	}
	@Override
	public Resp forbitCancle(SimpleUser simpleUser, int uid) {
		forbitUtil.deleteByUid(uid);
		return Resp.build(Code.OK, "解封账号成功");
	}

}
